/**
 * 
 */
package com.yidu.menuProject.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.menuProject.model.FoodModel;
import com.yidu.menuProject.model.MealModel;
import com.yidu.menuProject.model.SiteModel;
import com.yidu.menuProject.model.TuserModel;
import com.yidu.menuProject.service.personCenter;

/**
 * @author zoutian
 *date2018年7月12日
 * 
 */
@Controller
@RequestMapping("/PersonCenterAction")
public class PersonCenterAction {
	@Resource  
	private personCenter siteService;
	
	/**  
	 * 收货地址的显示方法
	 * @return 集合
	 */
	@RequestMapping("/findSite")
	@ResponseBody
	public List<SiteModel> findSite(HttpServletRequest request){
		TuserModel user= (TuserModel)request.getSession().getAttribute("tuserModel");
		List<SiteModel> list=siteService.findSite(user.getUserName());
		System.out.println(list.toString());
		return list;
	}
	/**
	 *根据用户ID查询用户收货地址
	 * @param userId 用户id
	 * @return 集合
	 */
	@RequestMapping("/showUpdateArea")
	@ResponseBody
	public List<SiteModel> showUpdateArea(String siteId){
		List<SiteModel> list=siteService.findSiteById(siteId);
		System.out.println(list.toString());
		return list;
	}
	
	
	/**
	 * 查询用户密码的方法
	 * @param userName 用户名
	 * @return 字符串
	 */
	@RequestMapping("/findPawd")
	@ResponseBody
	public String findPawd(HttpServletRequest request){
		TuserModel user= (TuserModel)request.getSession().getAttribute("tuserModel");
		String pawd=siteService.findPawd(user.getUserId());
		return pawd;
	}
	/**
	 * 修改密码
	 * @param userName 用户名
	 * @return 行数
	 */
	@RequestMapping("/updatePawd")
	public String updatePawd(String oper,HttpServletRequest request){
		TuserModel user= (TuserModel)request.getSession().getAttribute("tuserModel");
		int rows=siteService.updatePawd(oper,user.getUserId());
		return "html/member_pwd";
	}
	/**
	 * 增加收货地址的方法
	 * @param userName 用户名
	 * @param userPhone 用户电话号码
	 * @param siteName 收货地址
	 * @return 行数
	 */
	@RequestMapping("/addArea")
	@ResponseBody
	public int addArea( String userPhone,String siteName , HttpServletRequest request){
		TuserModel user= (TuserModel)request.getSession().getAttribute("tuserModel");
		int rows=siteService.addArea(user.getUserName(), userPhone, siteName);
		return rows;
	}
	/**
	 * 根据用户ID删除用户收货信息的方法
	 * @param userId 用户ID
	 * @return 行数
	 */
	@RequestMapping("/deleteResiverArea")
	@ResponseBody
	public int deleteResiverArea(String siteId){
		int rows=siteService.deleResivAreaTele(siteId);
		return rows;
	}
	/**
	 * 修改收货地址
	 * @param siteName 地址名称
	 * @param userPhone 用户电话号码
	 * @param userId 用户ID
	 * @return 字符串
	 */
	@RequestMapping("/updateAreaTele")
	@ResponseBody
	public int updateAreaTele(String siteName,String userPhone,String userId,String siteId){
		int rows=siteService.updateAreaTele(siteName, userPhone, userId,siteId);
		System.out.println("++++++++++++++++++++");
		return rows;
	}
	/**
	 * 查询我收藏的店铺方法
	 * @return 集合
	 */
	@RequestMapping("/findShop")
	@ResponseBody
	public List<MealModel> findShop(){
		String mealId="1";
		List<MealModel> list=siteService.findShop(mealId);
		return list;
	}
	/**
	 * 查询我收藏的食品
	 * @param foodId 食品ID
	 * @return 集合
	 */
//	@RequestMapping("/findFoodResoved")
//	@ResponseBody
//	public List<FoodModel> findFoodResoved(String foodId) {
//		foodId="2";
//		List<FoodModel> list=siteService.findFoodResoved(foodId);
//		return list;
//	}
	
}
